<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>设置品牌费率</title>
    <script src="js/lib/jquery-1.11.0.js"></script>
    <link rel="stylesheet" href="css/lib/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/lib/loading.css" />
    <script src="js/lib/bootstrap.min.js"></script>
    <script src="js/lib/loading.js"></script>
    <!--<script src="js/lib/angular.min.js"></script>-->
    <script src="js/base.js" type="text/javascript" charset="utf-8"></script>
</head>
<style>
    body{
        font-size:12px;
    }
    table,
    table td:nth-child(even) {

    }
    table tr:nth-child(even) {
        background-color:#ffffff;
    }
</style>
<body ng-app="myApp" ng-controller="customersCtrl">
<div class="">
    <!--加载动画-->
    <!--<div class="wrapper">
        <div id="loader-wrapper">
            <div id="loader"></div>
        </div>
    </div>-->
    <div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px;width:60%">
        <table class="table table-hover">
            <tbody>
            <tr>
                <th colspan="12">设置品牌普通用户费率：</th>
            </tr>
            <tr>
                <td>选择品牌:</td>
                <td colspan="12">
                    <select name="" id="msg1" type="text" class="form-control" style="width:280px;">
                        <option id="op"></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>选择现金通道:</td>
                <td colspan="12">
                    <select id="msg2" class="form-control" style="width:280px;" >
                       
                    </select>
                </td>

            </tr>
            <tr>
                <td>设置刷卡费率:</td>
                <td colspan="12">
                    <input id="msg3" class="form-control" type="text" style="width:280px;"/>
                </td>
            </tr>
            <tr>
                <td colspan="12" style="color:red">
                    <input id="btn" type="btn" value="设置" class="btn btn-danger"/>
                    PS：在此设置普通用户费率（最高费率  消费者级别费率  费率不能低于平台结算费率）
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
</div>
</body>
<script>
    $(function(){
        var brandid = sessionStorage.getItem(key=3);
        var brandname = sessionStorage.getItem(key=100);
        var userid =  sessionStorage.getItem(key=4);
        console.log(brandname);
        $('#op').val(brandid);
        $('#op').text(brandname);
        /*获取所有通道*/
        $.ajax({
            type:"POST",
            url:window.baseUrl+"user/channel/query/all/brandid",
            async:true,
            dataType:"json",
            data:{
                user_id:userid
            },
            success:function(data){               
                console.log(data.result)
                var html = "<option selected='selected' value=''>请选择通道</option>";
                var vendorJson = eval(data.result);
                for(var i=0; i<vendorJson.length; i++){
                html += "<option value= '"+vendorJson[i].id+"'>"+vendorJson[i].name+'--'+vendorJson[i].channelParams+"</option>";
                }
                $("#msg2").html('').append(html);
               
            },
            error:function(data){
                alert('失败')
            }
        });
     
        $('#btn').click(function(){
            var msg1 = $('#msg1').val();
            var msg2 = $('#msg2').val();
            var msg3 = $('#msg3').val();
            /*var msg4 = $('#msg4').val();*/
            console.log(msg1);
            console.log(msg2);
            console.log(msg3);
           /* console.log(msg4);*/
            if(msg1==""|| msg2==""|| msg3==""){
                alert('请确认输入信息')
            }else{
                $.ajax({
                    type:"POST",
                    url:window.baseUrl+"user/brandrate/add",/*设置普通用户的费率*/
                    async:true,
                    dataType:"json",
                    data:{
                        brand_id:msg1,
                        channel_id:msg2,
                        rate:msg3,
                        status:1,
                        with_draw_fee:5,
                        extra_fee:5
                    },
                    success:function(data){
                        /*alert(data.resp_message)*/
                        console.log(data)
                        if(data.resp_code == 000000){
                            alert("费率成功设置为"+data.result.rate);
                        }
                        if(data.resp_code == 999999){
                            alert("费率成功设置为"+data.resp_message);
                        }
                    },
                    error:function(data){
                        alert('失败')
                    }
                });
            }


        })
    });
</script>
</html>

